﻿@{
    ViewBag.Title = "Index";
}
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

    
<h2>Index</h2>
<form id="form" action="@Url.Action("Datos", "Home")">
    <input type="submit" value="MasterTabla" />
</form>

<div id='table_div'></div>

<script type='text/javascript'>
    google.load('visualization', '1', { packages: ['table'] });
      //google.setOnLoadCallback(drawTable);

      var form = $("#form");
      form.submit(funcion1);

      function funcion1() {
          var url = "@Url.Action("Datos", "Home")";
          var promesa = $.get(url);
          promesa.done(drawTable);
          return false;
      }

    function drawTable(datos) {
        var data = new google.visualization.DataTable();
        var options = { 'showRowNumber':true, 'width':'300px' };
          var i;
          console.log(datos);
        data.addColumn('string', 'Nombre');
        data.addColumn('string', 'tipo');
        data.addColumn('number', 'Valor');
        $.each(datos, function()
        {
            //console.log(this);
            
                data.addRows([
                    [this.nombre, this.tipo, this.valor]
                    //["hola", "holo", { v: 1000, f: "holis" }]
                ]);
            
            
            /*});
            /*console.log("termino");*/
                var table = new google.visualization.Table(document.getElementById('table_div'));
            
            table.draw(data, options);
        }
        );
    }
    </script>